<?php

class ChatWidget extends CWidget {

    public function init() {
    	$this->renderContent(); 
    }
    protected function renderContent() {
    	$criteria = new CDbCriteria();
  		$criteria->limit = 10;
  		$criteria->order ="id desc";
  		$lastId = Yii::app()->db->createCommand('SELECT id FROM tbl_chat ORDER BY id DESC LIMIT 1')->queryScalar();
    	$dataProvider=Chat::model()->findAll($criteria);
        $this->render('chat',array('model'=>$dataProvider,'id'=>$lastId ));
    }

}

?>